package queueDemo;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Dmeo3 {
    public static void main(String[] args) {
        BlockingQueue<Integer> queue3 = new ArrayBlockingQueue<Integer>(10);
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 2; i++) {
                queue3.offer(1);
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                try {
                    Thread.sleep(1000);
                    System.out.println(queue3.poll());
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
//            System.out.println("poll() 方法之后");
//            System.out.println(queue3.peek());
        });
        t1.start();
        t2.start();
    }
}
